package com.shrct.businessprocess.organization;

import com.shrct.businessprocess.organization.RCBusinessProcessorAssignment;
import com.shrct.businessprocess.organization.RCEmployee;
import com.shrct.businessprocess.organization.RCEmployeeDAO;
import com.shrct.businessprocess.organization.RCEnterprise;
import com.shrct.businessprocess.organization.RCOrganizationService;
import com.shrct.businessprocess.organization.RCSupplier;
import com.shrct.businessprocess.organization.impl.RCBusinessProcessorAssignmentImpl;
import com.shrct.businessprocess.product.RCProductMetaType;
import com.shrct.businessprocess.product.RCProductSpecification;
import com.shrct.businessprocess.product.impl.RCProductSpecificationImpl;
import edu.fudan.mylang.pf.test.BaseTest;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;

@ContextConfiguration(locations = "classpath:HibernateApplicationContext-test.xml")
public class InitData extends BaseTest {
  public InitData() {
    super();
  }
  
  @Autowired
  private RCOrganizationService organizationService;
  
  @Autowired
  private RCEmployeeDAO employeeDAO;
  
  @Rollback(value = false)
  @Test
  public void InitAdmin() {
    this.initEmployees();
    this.initOrganizations();
    this.initProductSpecifications();
  }
  
  public void initProductSpecifications() {RCProductSpecification rCProductSpecification=RCProductSpecificationImpl.create(getObjectFactory());
    final Procedure1<RCProductSpecification> _function = new Procedure1<RCProductSpecification>() {
        public void apply(final RCProductSpecification it) {
          it.setCode("PCIS0001");
          it.setProductMetaType(RCProductMetaType.identifiable);
        }
      };
    ObjectExtensions.<RCProductSpecification>operator_doubleArrow(rCProductSpecification, _function);RCProductSpecification rCProductSpecification_1=RCProductSpecificationImpl.create(getObjectFactory());
    final Procedure1<RCProductSpecification> _function_1 = new Procedure1<RCProductSpecification>() {
        public void apply(final RCProductSpecification it) {
          it.setCode("PCIS0002");
          it.setProductMetaType(RCProductMetaType.identifiable);
        }
      };
    ObjectExtensions.<RCProductSpecification>operator_doubleArrow(rCProductSpecification_1, _function_1);RCProductSpecification rCProductSpecification_2=RCProductSpecificationImpl.create(getObjectFactory());
    final Procedure1<RCProductSpecification> _function_2 = new Procedure1<RCProductSpecification>() {
        public void apply(final RCProductSpecification it) {
          it.setCode("PCIS0003");
          it.setProductMetaType(RCProductMetaType.identifiable);
        }
      };
    ObjectExtensions.<RCProductSpecification>operator_doubleArrow(rCProductSpecification_2, _function_2);RCProductSpecification rCProductSpecification_3=RCProductSpecificationImpl.create(getObjectFactory());
    final Procedure1<RCProductSpecification> _function_3 = new Procedure1<RCProductSpecification>() {
        public void apply(final RCProductSpecification it) {
          it.setCode("PIBM0001");
          it.setProductMetaType(RCProductMetaType.identifiable);
        }
      };
    ObjectExtensions.<RCProductSpecification>operator_doubleArrow(rCProductSpecification_3, _function_3);RCProductSpecification rCProductSpecification_4=RCProductSpecificationImpl.create(getObjectFactory());
    final Procedure1<RCProductSpecification> _function_4 = new Procedure1<RCProductSpecification>() {
        public void apply(final RCProductSpecification it) {
          it.setCode("PIBM0002");
          it.setProductMetaType(RCProductMetaType.identifiable);
        }
      };
    ObjectExtensions.<RCProductSpecification>operator_doubleArrow(rCProductSpecification_4, _function_4);RCProductSpecification rCProductSpecification_5=RCProductSpecificationImpl.create(getObjectFactory());
    final Procedure1<RCProductSpecification> _function_5 = new Procedure1<RCProductSpecification>() {
        public void apply(final RCProductSpecification it) {
          it.setCode("PIBM0003");
          it.setProductMetaType(RCProductMetaType.identifiable);
        }
      };
    ObjectExtensions.<RCProductSpecification>operator_doubleArrow(rCProductSpecification_5, _function_5);RCProductSpecification rCProductSpecification_6=RCProductSpecificationImpl.create(getObjectFactory());
    final Procedure1<RCProductSpecification> _function_6 = new Procedure1<RCProductSpecification>() {
        public void apply(final RCProductSpecification it) {
          it.setCode("ACIS0001");
          it.setProductMetaType(RCProductMetaType.anonymous);
        }
      };
    ObjectExtensions.<RCProductSpecification>operator_doubleArrow(rCProductSpecification_6, _function_6);RCProductSpecification rCProductSpecification_7=RCProductSpecificationImpl.create(getObjectFactory());
    final Procedure1<RCProductSpecification> _function_7 = new Procedure1<RCProductSpecification>() {
        public void apply(final RCProductSpecification it) {
          it.setCode("ACIS0002");
          it.setProductMetaType(RCProductMetaType.anonymous);
        }
      };
    ObjectExtensions.<RCProductSpecification>operator_doubleArrow(rCProductSpecification_7, _function_7);RCProductSpecification rCProductSpecification_8=RCProductSpecificationImpl.create(getObjectFactory());
    final Procedure1<RCProductSpecification> _function_8 = new Procedure1<RCProductSpecification>() {
        public void apply(final RCProductSpecification it) {
          it.setCode("ACIS0003");
          it.setProductMetaType(RCProductMetaType.anonymous);
        }
      };
    ObjectExtensions.<RCProductSpecification>operator_doubleArrow(rCProductSpecification_8, _function_8);RCProductSpecification rCProductSpecification_9=RCProductSpecificationImpl.create(getObjectFactory());
    final Procedure1<RCProductSpecification> _function_9 = new Procedure1<RCProductSpecification>() {
        public void apply(final RCProductSpecification it) {
          it.setCode("AIBM0001");
          it.setProductMetaType(RCProductMetaType.anonymous);
        }
      };
    ObjectExtensions.<RCProductSpecification>operator_doubleArrow(rCProductSpecification_9, _function_9);RCProductSpecification rCProductSpecification_10=RCProductSpecificationImpl.create(getObjectFactory());
    final Procedure1<RCProductSpecification> _function_10 = new Procedure1<RCProductSpecification>() {
        public void apply(final RCProductSpecification it) {
          it.setCode("AIBM0002");
          it.setProductMetaType(RCProductMetaType.anonymous);
        }
      };
    ObjectExtensions.<RCProductSpecification>operator_doubleArrow(rCProductSpecification_10, _function_10);RCProductSpecification rCProductSpecification_11=RCProductSpecificationImpl.create(getObjectFactory());
    final Procedure1<RCProductSpecification> _function_11 = new Procedure1<RCProductSpecification>() {
        public void apply(final RCProductSpecification it) {
          it.setCode("AIBM0003");
          it.setProductMetaType(RCProductMetaType.anonymous);
        }
      };
    ObjectExtensions.<RCProductSpecification>operator_doubleArrow(rCProductSpecification_11, _function_11);
  }
  
  public void initOrganizations() {
    RCEnterprise _registerEnterprise = this.organizationService.registerEnterprise("0000001");
    final Procedure1<RCEnterprise> _function = new Procedure1<RCEnterprise>() {
        public void apply(final RCEnterprise it) {
          it.setName("\u4E91\u591A\u79D1\u6280");
          it.setIsBuildin(Boolean.valueOf(true));
        }
      };
    ObjectExtensions.<RCEnterprise>operator_doubleArrow(_registerEnterprise, _function);
    RCEnterprise _registerEnterprise_1 = this.organizationService.registerEnterprise("0000002");
    final Procedure1<RCEnterprise> _function_1 = new Procedure1<RCEnterprise>() {
        public void apply(final RCEnterprise p) {
          p.setName("\u4F01\u4E1A2");
          RCEnterprise _registerEnterprise = InitData.this.organizationService.registerEnterprise("0000021");
          final Procedure1<RCEnterprise> _function = new Procedure1<RCEnterprise>() {
              public void apply(final RCEnterprise it) {
                it.setName("\u4F01\u4E1A2-1");
                it.setParent(p);
              }
            };
          ObjectExtensions.<RCEnterprise>operator_doubleArrow(_registerEnterprise, _function);
          RCEnterprise _registerEnterprise_1 = InitData.this.organizationService.registerEnterprise("0000022");
          final Procedure1<RCEnterprise> _function_1 = new Procedure1<RCEnterprise>() {
              public void apply(final RCEnterprise it) {
                it.setName("\u4F01\u4E1A2-2");
                it.setParent(p);
              }
            };
          ObjectExtensions.<RCEnterprise>operator_doubleArrow(_registerEnterprise_1, _function_1);
        }
      };
    ObjectExtensions.<RCEnterprise>operator_doubleArrow(_registerEnterprise_1, _function_1);
    RCEnterprise _registerEnterprise_2 = this.organizationService.registerEnterprise("0000003");
    final Procedure1<RCEnterprise> _function_2 = new Procedure1<RCEnterprise>() {
        public void apply(final RCEnterprise it) {
          it.setName("\u4F01\u4E1A3");
        }
      };
    ObjectExtensions.<RCEnterprise>operator_doubleArrow(_registerEnterprise_2, _function_2);
    RCEnterprise _registerEnterprise_3 = this.organizationService.registerEnterprise("0000004");
    final Procedure1<RCEnterprise> _function_3 = new Procedure1<RCEnterprise>() {
        public void apply(final RCEnterprise it) {
          it.setName("\u4F01\u4E1A4");
        }
      };
    ObjectExtensions.<RCEnterprise>operator_doubleArrow(_registerEnterprise_3, _function_3);
    RCEnterprise _registerEnterprise_4 = this.organizationService.registerEnterprise("0000005");
    final Procedure1<RCEnterprise> _function_4 = new Procedure1<RCEnterprise>() {
        public void apply(final RCEnterprise it) {
          it.setName("\u4F01\u4E1A5");
        }
      };
    ObjectExtensions.<RCEnterprise>operator_doubleArrow(_registerEnterprise_4, _function_4);
    RCSupplier _registerSupplier = this.organizationService.registerSupplier("0000001");
    final Procedure1<RCSupplier> _function_5 = new Procedure1<RCSupplier>() {
        public void apply(final RCSupplier it) {
          it.setName("\u4F9B\u5E94\u55461");
        }
      };
    ObjectExtensions.<RCSupplier>operator_doubleArrow(_registerSupplier, _function_5);
  }
  
  public void initEmployees() {
    RCEmployee _registerEmployee = this.organizationService.registerEmployee("C12");
    final Procedure1<RCEmployee> _function = new Procedure1<RCEmployee>() {
        public void apply(final RCEmployee it) {
          it.setName("\u5458\u5DE512[\u5546\u52A1]");
          InitData.this.organizationService.registerRoleAssignment("BusinessProcessor", it);
          InitData.this.organizationService.registerRoleAssignment("Tester", it);
        }
      };
    final RCEmployee bizMan12 = ObjectExtensions.<RCEmployee>operator_doubleArrow(_registerEmployee, _function);
    RCEmployee _registerEmployee_1 = this.organizationService.registerEmployee("C13");
    final Procedure1<RCEmployee> _function_1 = new Procedure1<RCEmployee>() {
        public void apply(final RCEmployee it) {
          it.setName("\u5458\u5DE513[\u5546\u52A1]");
          InitData.this.organizationService.registerRoleAssignment("BusinessProcessor", it);
          InitData.this.organizationService.registerRoleAssignment("Tester", it);
        }
      };
    final RCEmployee bizMan13 = ObjectExtensions.<RCEmployee>operator_doubleArrow(_registerEmployee_1, _function_1);
    RCEmployee _registerEmployee_2 = this.organizationService.registerEmployee("C14");
    final Procedure1<RCEmployee> _function_2 = new Procedure1<RCEmployee>() {
        public void apply(final RCEmployee it) {
          it.setName("\u5458\u5DE514[\u5546\u52A1]");
          InitData.this.organizationService.registerRoleAssignment("BusinessProcessor", it);
          InitData.this.organizationService.registerRoleAssignment("Tester", it);
        }
      };
    final RCEmployee bizMan14 = ObjectExtensions.<RCEmployee>operator_doubleArrow(_registerEmployee_2, _function_2);
    RCEmployee _findByEid = this.employeeDAO.findByEid("admin");
    final Procedure1<RCEmployee> _function_3 = new Procedure1<RCEmployee>() {
        public void apply(final RCEmployee e) {
          InitData.this.organizationService.registerRoleAssignment("RCSales", e);
          InitData.this.organizationService.registerRoleAssignment("Tester", e);
          e.setName("\u7CFB\u7EDF\u7BA1\u7406\u5458");RCBusinessProcessorAssignment rCBusinessProcessorAssignment=RCBusinessProcessorAssignmentImpl.create(getObjectFactory());
          final Procedure1<RCBusinessProcessorAssignment> _function = new Procedure1<RCBusinessProcessorAssignment>() {
              public void apply(final RCBusinessProcessorAssignment it) {
                it.setBusinessMan(bizMan12);
                it.setSaler(e);
              }
            };
          ObjectExtensions.<RCBusinessProcessorAssignment>operator_doubleArrow(rCBusinessProcessorAssignment, _function);
        }
      };
    ObjectExtensions.<RCEmployee>operator_doubleArrow(_findByEid, _function_3);
    RCEmployee _registerEmployee_3 = this.organizationService.registerEmployee("C01");
    final Procedure1<RCEmployee> _function_4 = new Procedure1<RCEmployee>() {
        public void apply(final RCEmployee it) {
          it.setName("\u5458\u5DE51[\u603B\u7ECF\u7406]");
          InitData.this.organizationService.registerRoleAssignment("CEO", it);
          InitData.this.organizationService.registerRoleAssignment("Tester", it);
        }
      };
    ObjectExtensions.<RCEmployee>operator_doubleArrow(_registerEmployee_3, _function_4);
    RCEmployee _registerEmployee_4 = this.organizationService.registerEmployee("C02");
    final Procedure1<RCEmployee> _function_5 = new Procedure1<RCEmployee>() {
        public void apply(final RCEmployee e) {
          e.setName("\u5458\u5DE52[\u9500\u552E\u4E3B\u7BA1,\u9500\u552E]");
          InitData.this.organizationService.registerRoleAssignment("RCSales", e);
          InitData.this.organizationService.registerRoleAssignment("SalesLeader", e);
          InitData.this.organizationService.registerRoleAssignment("Tester", e);RCBusinessProcessorAssignment rCBusinessProcessorAssignment=RCBusinessProcessorAssignmentImpl.create(getObjectFactory());
          final Procedure1<RCBusinessProcessorAssignment> _function = new Procedure1<RCBusinessProcessorAssignment>() {
              public void apply(final RCBusinessProcessorAssignment it) {
                it.setBusinessMan(bizMan12);
                it.setSaler(e);
              }
            };
          ObjectExtensions.<RCBusinessProcessorAssignment>operator_doubleArrow(rCBusinessProcessorAssignment, _function);
        }
      };
    ObjectExtensions.<RCEmployee>operator_doubleArrow(_registerEmployee_4, _function_5);
    RCEmployee _registerEmployee_5 = this.organizationService.registerEmployee("C03");
    final Procedure1<RCEmployee> _function_6 = new Procedure1<RCEmployee>() {
        public void apply(final RCEmployee e) {
          e.setName("\u5458\u5DE53[\u9500\u552E]");
          InitData.this.organizationService.registerRoleAssignment("RCSales", e);
          InitData.this.organizationService.registerRoleAssignment("Tester", e);RCBusinessProcessorAssignment rCBusinessProcessorAssignment=RCBusinessProcessorAssignmentImpl.create(getObjectFactory());
          final Procedure1<RCBusinessProcessorAssignment> _function = new Procedure1<RCBusinessProcessorAssignment>() {
              public void apply(final RCBusinessProcessorAssignment it) {
                it.setBusinessMan(bizMan13);
                it.setSaler(e);
              }
            };
          ObjectExtensions.<RCBusinessProcessorAssignment>operator_doubleArrow(rCBusinessProcessorAssignment, _function);
        }
      };
    ObjectExtensions.<RCEmployee>operator_doubleArrow(_registerEmployee_5, _function_6);
    RCEmployee _registerEmployee_6 = this.organizationService.registerEmployee("C04");
    final Procedure1<RCEmployee> _function_7 = new Procedure1<RCEmployee>() {
        public void apply(final RCEmployee e) {
          e.setName("\u5458\u5DE54[\u9500\u552E]");
          InitData.this.organizationService.registerRoleAssignment("RCSales", e);
          InitData.this.organizationService.registerRoleAssignment("Tester", e);RCBusinessProcessorAssignment rCBusinessProcessorAssignment=RCBusinessProcessorAssignmentImpl.create(getObjectFactory());
          final Procedure1<RCBusinessProcessorAssignment> _function = new Procedure1<RCBusinessProcessorAssignment>() {
              public void apply(final RCBusinessProcessorAssignment it) {
                it.setBusinessMan(bizMan14);
                it.setSaler(e);
              }
            };
          ObjectExtensions.<RCBusinessProcessorAssignment>operator_doubleArrow(rCBusinessProcessorAssignment, _function);
        }
      };
    ObjectExtensions.<RCEmployee>operator_doubleArrow(_registerEmployee_6, _function_7);
    RCEmployee _registerEmployee_7 = this.organizationService.registerEmployee("C05");
    final Procedure1<RCEmployee> _function_8 = new Procedure1<RCEmployee>() {
        public void apply(final RCEmployee it) {
          it.setName("\u5458\u5DE55[\u91C7\u8D2D\u7ECF\u7406]");
          InitData.this.organizationService.registerRoleAssignment("RCPurchaseLeader", it);
          InitData.this.organizationService.registerRoleAssignment("Tester", it);
        }
      };
    ObjectExtensions.<RCEmployee>operator_doubleArrow(_registerEmployee_7, _function_8);
    RCEmployee _registerEmployee_8 = this.organizationService.registerEmployee("C06");
    final Procedure1<RCEmployee> _function_9 = new Procedure1<RCEmployee>() {
        public void apply(final RCEmployee it) {
          it.setName("\u5458\u5DE57[\u8D22\u52A1\u7ECF\u7406]");
          InitData.this.organizationService.registerRoleAssignment("RCFinanceLeader", it);
          InitData.this.organizationService.registerRoleAssignment("Tester", it);
        }
      };
    ObjectExtensions.<RCEmployee>operator_doubleArrow(_registerEmployee_8, _function_9);
    RCEmployee _registerEmployee_9 = this.organizationService.registerEmployee("C07");
    final Procedure1<RCEmployee> _function_10 = new Procedure1<RCEmployee>() {
        public void apply(final RCEmployee it) {
          it.setName("\u5458\u5DE58[\u8D22\u52A1]");
          InitData.this.organizationService.registerRoleAssignment("RCFinanceMan", it);
          InitData.this.organizationService.registerRoleAssignment("Tester", it);
        }
      };
    ObjectExtensions.<RCEmployee>operator_doubleArrow(_registerEmployee_9, _function_10);
    RCEmployee _registerEmployee_10 = this.organizationService.registerEmployee("C08");
    final Procedure1<RCEmployee> _function_11 = new Procedure1<RCEmployee>() {
        public void apply(final RCEmployee it) {
          it.setName("\u5458\u5DE59[\u5546\u52A1\u7ECF\u7406]");
          InitData.this.organizationService.registerRoleAssignment("BusinessLeader", it);
          InitData.this.organizationService.registerRoleAssignment("Tester", it);
        }
      };
    ObjectExtensions.<RCEmployee>operator_doubleArrow(_registerEmployee_10, _function_11);
  }
}
